$(function(){
	var login = $('#login');
	$('#loginbt').on('click',function(){
		var schoolId = login.find('input:eq(0)').val();
		var password = login.find('input:eq(1)').val();
		var reg = /51201\d{5}/g;
		var name = reg.exec(schoolId);
		name = name?name[0]:0;
		//console.log(name);
		if(name === schoolId){
			if(schoolId === password){
				$.ajax({
					type:'post',
					url:'/api/login',
					data:{
						schoolId:schoolId,
						password:password,
						root:login.find('input:eq(0)').val() == '5120152576'?0:
								login.find('input:eq(0)').val() == '5120152534'?0:
								login.find('input:eq(0)').val() == '5120152499'?0:1
					},
					dataType:'json',
					success:function(data){
						// console.log('用户数据反馈成功');
						// console.log(data);
						location.href = '/main';
					}
				});
			}
			else{
				login.find('p:eq(1)').animate({opacity:1},function(){
					login.find('p:eq(1)').animate({opacity:0},1000);
				});
			}
		}
		else{
			login.find('p:eq(0)').animate({opacity:1},function(){
				login.find('p:eq(0)').animate({opacity:0},1000);
			});
		}
	});
})